﻿CREATE proc [dbo].[NKNH_Sua_L]  
@ID bigint,  
@NHID bigint,  
@tk nvarchar(255),  
@chitiet_tk nvarchar(255),  
@sotien float,  
@ngoaite float,  
@noidung nvarchar(255) ,  
@tenhhdv nvarchar(255),  
@ghichu nvarchar(255),  
@tle_vat float,  
 
@loai nvarchar(255),  

@masothue nvarchar(255),  
@so_seri nvarchar(255),  
@tenkh nvarchar(255),  
@malctte nvarchar(255),  
@so_hdon nvarchar(255)  
as  
--select*from NKNH_L  
 if exists(select * from NKNH_L   
  Where NHID  <>@NHID  and ID=@ID )  
  begin  
  select ErrCode=0   
  end   
  else  
  begin  
  update NKNH_L set tk= @tk ,chitiet_tk=@chitiet_tk ,so_tien=@sotien ,  
     ngoaite=@ngoaite ,noi_dung=@noidung  ,  
     tenhhdv=@tenhhdv ,ghichu=@ghichu ,tle_vat=@tle_vat,  
     tien_vat=@sotien*@tle_vat/100 ,loai=@loai ,nt_vat=@ngoaite*@tle_vat/100 ,  
     masothue=@masothue ,so_seri=@so_seri ,tenkh=@tenkh,  
     malctte=@malctte ,so_hdon=@so_hdon  
 where ID=@ID and  NHID=@NHID  
 select ErrCode=1      
  end 